<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!-- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">-->
<%
	response.setHeader("Cache-Control", "no-cache");
	response.setHeader("Pragma", "no-cache");
	response.setDateHeader("Expires", 0);
%>
<html>
<%@ taglib prefix="f" uri="/WEB-INF/tlds/ext-tags.tld"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><s:property value="busiMap.get('FUN_TITLE')" /></title>

<f:commonSource path="../../../resources/libs"
	extentionJs="yss_panels.js,mySimpleGird.js,Ext.ux.form.LovCombo.js,TreeGrid.js,uxmedia.js,uxflash.js,uxfusion.js,SmartCheckboxSelectionModel.js"
	extentionCss="list.css,Ext.ux.form.LovCombo.css,TreeGrid.css,SmartCheckboxSelectionModel.css" />

</head>
<script type="text/javascript">
var Status, CHOOSEWORKFLOW, NOWORKFLOW,ERROR_INFO,DOSUCCESS,FAILED,FUNDINISNULL,dataerror,SENDSUCCESS;//提示信息

//js中获取当前日期
function getTodayDate(){
	Date.prototype.format = function(format){
		var o = {
			"M+" : this.getMonth()+1, //month
			
			"d+" : this.getDate(), //day
			
			"h+" : this.getHours(), //hour
			
			"m+" : this.getMinutes(), //minute
			
			"s+" : this.getSeconds(), //second
			
			"q+" : Math.floor((this.getMonth()+3)/3), //quarter
			
			"S" : this.getMilliseconds() //millisecond
		}
		if(/(y+)/.test(format))
		format=format.replace(RegExp.$1,(this.getFullYear()+"").substr(4 - RegExp.$1.length));
		for(var k in o)
			if(new RegExp("("+ k +")").test(format))
			format = format.replace(RegExp.$1,RegExp.$1.length==1 ? o[k] :("00"+ o[k]).substr((""+ o[k]).length));
			return format;
	}
	
	var ddd = new Date();
	var todayDate = ddd.format('yyyyMMdd');
	return todayDate;
}

</script>
<body>
<div class="content"><!-- 标题 -->
<div class="header">
<div class="title"><s:property value="busiMap.get('FUN_TITLE')" /></div>
</div>

<!-- 查询区域begin -->
<div class="queryArea" id="class1content" >
<form action="#" id="form">
<table width='50%'>
	<tr>
		<td align='right' width='20%'><s:property
			value="busiMap.get('BEGINDATE')" />: &nbsp;</td>
		<td align='left' id='jx_c10Div' width='20%'></td>
		<td align='right' width='20%'><s:property
			value="busiMap.get('ENDDATE')" />: &nbsp;</td>
		<td align='left' id='jx_c2Div' width='20%'></td>
		<td align='center' width='40%'>
		
		</td>
	</tr>
</table>
</form>
</div>
<!-- 查询区域 end--> 
<div class="grid" id="grid"></div>
<table align='center'>
			<tr class='butw'>
				<td>
				<div id="do"></div>
				</td>
			</tr>
		</table>

</div>
</body>
<f:onready params="params">

<f:datefield name="begindate" id="begindate" allowBlank="false" renderTo="jx_c10Div"></f:datefield>
<f:datefield name="enddate" id="enddate" allowBlank="false" renderTo="jx_c2Div"></f:datefield>
/*<f:grid gridData="gridData" stripeRows='true' height='500' id='grid' selectType="check"
		title="%{busiMap['GRID_TITLE_ONE']}" renderTo="grid" forceFit="false">
	</f:grid>*/
var data = <s:property value="data"/>;	


            var record_9757 = Ext.data.Record.create([{
                name: 'checked'
            }, {
                name: 'disenable'
            }, {
                name: 'entityname'
            }, {
                name: 'workflowname'
            }, {
                name: 'type'
            }, {
                name: 'typecode'
            }, {
                name: '_id'
            }, {
                name: '_parent'
            }, {
                name: '_level',
                type: 'int'
            }, {
                name: '_lft',
                type: 'int'
            }, {
                name: '_rgt',
                type: 'int'
            }, {
                name: '_is_leaf',
                type: 'bool'
            }]);
            var store_9757 = new Ext.ux.maximgb.treegrid.NestedSetStore({
                autoLoad: true,
                reader: new Ext.data.JsonReader({
                    id: '_id'
                }, record_9757),
                proxy: new Ext.data.MemoryProxy(data)
            });
            var sm_9757 = new Ext.grid.SmartCheckboxSelectionModel({
                header: '',
				dataIndex: 'checked'
            });
            new Ext.ux.maximgb.treegrid.GridPanel({
                id: 'grid',
                store: store_9757,
                master_column_id: 'entityname',
                renderTo: 'grid',
                stripeRows: true,
                columns: [sm_9757, {
                    id: 'entityname',
                    header: '<s:property value="busiMap['ENTITYNAME']"/>',
                    dataIndex: 'entityname',
                    width: 500,
                    sortable: true
                }, {
                    id: 'workflowname',
                    header: '<s:property value="busiMap['WORKFLOWNAME']"/>',
                    dataIndex: 'workflowname',
                    width: 350,
                    sortable: true
                }, {
                    id: 'type',
                    header: '<s:property value="busiMap['TYPE']"/>',
                    dataIndex: 'type',
                    width: 100,
                    sortable: true
                }, {
                    id: 'typecode',
                    header: 'TYPECODE',
                    dataIndex: 'typecode',
                    hidden: true,
                    width: 100,
                    sortable: true
                }],
                height: 500,
                collapsible: false,
                tbar: [yss.util.excel.createGrid2ExcelButton('grid'), yss.util.popupGrid('grid')],
                sm: sm_9757
            });






<f:button text="%{busiMap['DOWEBSERVICE']}" id="do"></f:button>
            Ext.getCmp("do").render("do");
            Ext.getCmp("do").on('click', function(){
                //alert(Ext.getCmp("grid").getSelectionModel().getSelections().length);
                if (Ext.getCmp("begindate").isValid() && Ext.getCmp("enddate").isValid() && dateIsValid()) {
                    var workflowname = "";
                    var entityCode = "";
                    var type = "";
                    var painnercodes = parent.Ext.getCmp('portfoliotree').getFrame().dom.contentWindow.Ext.getCmp("childportfolio").getValue();
                    var beginDate = Ext.util.Format.date(Ext.getCmp("begindate").getValue(), "Ymd");
                    var endDate = Ext.util.Format.date(Ext.getCmp("enddate").getValue(), "Ymd");
                    if ("" != painnercodes) {
                        //alert(painnercodes);
                        painnercodes = painnercodes.substring(0, painnercodes.length - 1);
                    }
                    entityCode =  getworkflowinfo(painnercodes);
                    if (entityCode!="error") {
                        Ext.Ajax.request({
                            url: 'checkworkflow.action',
                            //提交参数组 
                            method: 'post',
                            params: {
                                "dataMap['entitycode']": entityCode,
                                "dataMap['beginDate']": beginDate,
                                "dataMap['endDate']": endDate,
                                "dataMap['painnercodes']": painnercodes//410006
                            },
                            //成功时回调 
                            success: function(response, options){
							   //alert(response.responseText);
                              // var strObj = Ext.util.JSON.decode(response.responseText);
								var message = eval(response.responseText);
                                if (message=="true") {
				 					Ext.Ajax.request({
				                            url: 'doworkflow.action',
				                            //提交参数组 
				                            method: 'post',
				                            params: {
				                                "dataMap['entitycode']": entityCode,
				                                "dataMap['beginDate']": beginDate,
				                                "dataMap['endDate']": endDate,
				                                "dataMap['painnercodes']": painnercodes//410006
				                            },
				                            //成功时回调 
				                            success: function(response, options){
				                               /*var strObj = Ext.util.JSON.decode(response.responseText);
												var flag = strObj['flag'];
				                                if (flag) {
				                                    Ext.MessageBox.alert(Status, message);
				                                }*/
				                            }
				                        });
				                        Ext.MessageBox.alert(Status, SENDSUCCESS,function(ret){
											if (ret == "ok") {
												var now=new Date();
												var year=now.getYear();
												var month=now.getMonth();
												var date=now.getDate();
												month=month+1;
												if(month<10) month="0"+month;
												if(date<10) date="0"+date;
												var bizdate = year+""+month+""+date+"";
										       //	location.href = "initdatalogcenter.action?dataMap['begindate']="+bizdate+"&&dataMap['enddate']="+bizdate;
									        }
										});
                                }else {
                                    Ext.MessageBox.alert(Status, message);
                                }
                            }
                        });
                    }
                }
            })


	<s:if test="null!=commonMap.get('STATUS')">
Status = '<s:property value="commonMap.get('STATUS')" />';
</s:if>



	<s:if test="null!=busiMap.get('CHOOSEWORKFLOW')">
CHOOSEWORKFLOW = '<s:property value="busiMap.get('CHOOSEWORKFLOW')" />';
</s:if>

	<s:if test="null!=busiMap.get('NOWORKFLOW')">
NOWORKFLOW = '<s:property value="busiMap.get('NOWORKFLOW')" />';
</s:if>



	<s:if test="null!=busiMap.get('ERROR_INFO')">
ERROR_INFO = '<s:property value="busiMap.get('ERROR_INFO')" />';
</s:if>

	<s:if test="null!=busiMap.get('DOSUCCESS')">
DOSUCCESS = '<s:property value="busiMap.get('DOSUCCESS')" />';
</s:if>

	<s:if test="null!=busiMap.get('FAILED')">
FAILED = '<s:property value="busiMap.get('FAILED')" />';
</s:if>

	<s:if test="null!=busiMap.get('FUNDINISNULL')">
FUNDINISNULL = '<s:property value="busiMap.get('FUNDINISNULL')" />';
</s:if>

	<s:if test="null!=busiMap.get('DATAERROR')">
dataerror = '<s:property value="busiMap.get('DATAERROR')" />';
</s:if>

	<s:if test="null!=busiMap.get('SENDSUCCESS')">
SENDSUCCESS = '<s:property value="busiMap.get('SENDSUCCESS')" />';
</s:if>

//初始化每个日历控件为当前日期
Ext.getCmp('begindate').setValue(getTodayDate());
Ext.getCmp('enddate').setValue(getTodayDate());
</f:onready>
<script type="text/javascript">
function dateIsValid(){
	if (null != Ext.getCmp("begindate").getValue()
			&& null != Ext.getCmp("enddate").getValue()) {
		if (Ext.getCmp("begindate").getValue() > Ext.getCmp("enddate")
				.getValue()) {
			Ext.MessageBox.alert(Status, dataerror);
			return false;
		}
	}
	return true;
}
function getworkflowinfo(pacode){
    var entityCode = "";
    var workflowname = "";
    var flag = "error";
    if (0 == Ext.getCmp("grid").getSelectionModel().getSelections().length) {//未选任务
        Ext.MessageBox.alert(Status, CHOOSEWORKFLOW);
    }
    for (var i = 0; i < Ext.getCmp("grid").getSelectionModel().getSelections().length; i++) {
        var record = Ext.getCmp("grid").getSelectionModel().getSelections()[i];
        entityCode += record.get("_id") + "-" + record.get("workflowname") + "-" + record.get("typecode") + ",";
        if ("-" == record.get("workflowname")) {// 选择的不是实体或没有可执行任务
            Ext.MessageBox.alert(Status, NOWORKFLOW);
            return flag;
        }
        if ("" == pacode && (record.get("typecode") == 1 || record.get("typecode") == 2)) {//非咨询类必须选择组合
            Ext.MessageBox.alert(Status, FUNDINISNULL);
            return flag;
        }
    }
    if (0 != Ext.getCmp("grid").getSelectionModel().getSelections().length) {
        return entityCode.substring(0, entityCode.length - 1);
    }
    return flag;
}
</script>
</html>